using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Media;
using System.Windows;
using System.Windows.Markup;

namespace ViewOn.Helper.WPF
{
    static public class XAMLLoader
    {
        static public DependencyObject Interpret(string filePath)
        {
            StreamReader reader = new StreamReader(filePath);
            return Interpret(reader);
        }

        static public DependencyObject Interpret(StreamReader reader)
        {
            DependencyObject rootObject = XamlReader.Load(reader.BaseStream) as DependencyObject;
            return rootObject;
        }

        static public DependencyObject InterpretAsync(string filePath)
        {
            StreamReader reader = new StreamReader(filePath);
            return Interpret(reader);
        }

        static public DependencyObject InterpretAsync(StreamReader reader)
        {
            XamlReader r = new XamlReader();
            return (DependencyObject)r.LoadAsync(reader.BaseStream);
        }
    }
}
